<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <!-- 使用方法和charAt()相同 ,不同的是返回值是Unicode 编码。
        字符对应的Unicode 编码请百度
        语法:string.charCodeAt(index:字符的索引)
    -->
    <!-- w3c实例 -->
    <script>
        var text = "这是测试charCodeAt()";
        console.log("返回值是:" + text.charCodeAt(2));
    </script>

    <!-- 
        fromCharCode():与charCodeAt()相反  是将Unicode 编码装换位字符 
        语法:String.charCodeAt(index:Unicode 编码)
    -->
    <!-- w3c实例 -->
    <script>
        var text = String.fromCharCode(125); //注意:fromCharCode前面必须是String
        console.log(text);
    </script>
</body>

</html>